-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of a few types #10
base: master
Are you sure you want to change the base?
Conversation
Hey @timotejroiko, thanks so much for this! I'll take a look as soon as I have some time. |
Hey @timotejroiko, So I have to apologize. I had a bunch of MegaHash changes in my local repo from many months ago that I didn't finish, and kind of forgot about. I really wanted to get those committed, pushed and tagged before I worked on your fork. Part of these changes was cleaning up the repo folders a bit, and I moved the test scripts into a new Would it be possible for you to move your test script into there as well? Also, can we rename it from I think most of your other changes are "mergeable", and won't conflict with what I changed. Thanks, and sorry! |
no worries :) im working on some other stuff but i'll get back on it soon. |
### package.json Update dependencies ### test.js Added tests for: * Empty String * BigInt > 64 bit * NaN * Infinity * Undefined * Function ### test-bench2.js Added benchmarks for measuring performance of different data types ### main.js Changes: * separate and clarify flag-only data types * added flags for: true, false, big bigint, nan, infinity, undefined, function * changed Buffer.alloc to Buffer.allocUnsafe (faster) * add support for big bigint (>64bit, stored as hex buffer) * serialize functions and retrieve actual functions instead of string representation (breaking change) * store undefined as flag and retrieve actual undefined instead of "undefined" (breaking change) ### hash.cc Added short-circuiting for flag-only types ### Performance changes: * Numbers -> 50% faster writes * Booleans -> 100% faster writes and 200% faster reads * Bigint -> 50% faster writes * Big Bigint -> no longer throws, performance is a bit slower than strings * Null -> 50% faster writes, 200% faster reads * NaN -> 100% faster writes, 200% faster reads * Infinity -> 100% faster writes, 200% faster reads * Undefined -> 50% faster writes, 200% faster reads * Function -> now returns an actual function, performance is a bit slower than objects
i've rebased and moved the file to the test folder, let me know if theres anything else i can do :) |
Any update on these @jhuckaby? These PRs look pretty great in what they can provide for the repo |
Hey,
I ended up focusing on some improvements for the less important data types and flags. Additionally i added some more tests and updated dependencies because why not.
Anyways feel free to take a look, test and pick what you like. If you don't like some specific change let me know and i'll revert
Cheers!
package.json
Update dependencies
test.js
Added tests for:
test-bench2.js
Added benchmarks for measuring performance of different data types
main.js
Changes:
hash.cc
Added short-circuiting for flag-only types
Performance changes: